package com.gxy.learn.web;

import com.gxy.learn.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private TestService service;

    /**
     * 使用注解进行流控
     *
     * @return
     */
    @GetMapping(value = "/taskFlow")
    public String taskFlow() {
        return service.taskFlow("O(∩_∩)O哈哈~");
    }

    /**
     * 使用注解进行流控
     *
     * @return
     */
    @GetMapping(value = "/taskFlowException")
    public String taskFlowException() {
        return service.taskFlowException("O(∩_∩)O哈哈~");
    }

    /**
     * 使用注解进行降级
     *
     * @return
     */
    @GetMapping(value = "/taskFlowDown")
    public String taskFlowDown() {
        return service.taskFlowDown("O(∩_∩)O哈哈~");
    }

    /**
     * @param name
     * @return
     */
    @GetMapping(value = "/hello/{name}")
    public String hello(@PathVariable String name) {
        return service.apiHello(name);
    }
}
